<%--@elvariable id="webRoot" type="com.doupi.partner.op.interceptor.OpFilter"--%>
<%--@elvariable id="type" type="com.doupi.partner.op.controller.partner.PartnerController.index"--%>

<%@ page language="java" pageEncoding="UTF-8" %>
<%@ include file="../common/tags.jsp" %>

<!DOCTYPE html>
<html>
<head lang="en">
    <%@include file="../common/assets.jsp" %>
</head>
<body>
<!-- header -->
<%@include file="../common/header.jsp" %>

<!-- main start -->
<div class="am-cf admin-main">
    <!-- left menu start -->
    <%@include file="../common/menu.jsp" %>
    <!-- left menu end -->

    <!-- content start -->
    <div class="admin-content">

        <div class="am-cf am-padding">
            <div class="am-fl am-cf">
                <strong class="am-text-primary am-text-lg">合伙人</strong> /
                <small>
                    ${util:getPartnerTypeByCode(type).name}
                </small>
            </div>
        </div>

        <div class="am-g">

            <div class="am-u-sm-12 am-u-md-4 am-text-left">
                <util:wholePermission name="partner:${type}:add">
                    <a href="${webRoot}/partner/${type}/edit/0" class="am-btn am-btn-default">添加</a>
                </util:wholePermission>
                <util:logicPermissionTag name="!partner:${type}:add">&nbsp;</util:logicPermissionTag>
            </div>
            <div class="am-u-sm-12 am-u-md-8 am-form-group">
                <div class="am-g">
                    <%-- <div class="am-u-sm-12 am-u-md-4">
                         <div class="am-input-group">
                             <span class="am-input-group-label">起始时间</span>
                             <input id='begin_date' type="text" class="am-form-field" readonly="readonly">
                         </div>
                     </div>
                     <div class="am-u-sm-12 am-u-md-4">
                         <div class="am-input-group">
                             <span class="am-input-group-label">终止时间</span>
                             <input id='end_date' type="text" class="am-form-field" readonly="readonly">
                         </div>
                     </div>--%>
                    <div class="am-u-sm-12 am-u-md-4">
                        <div class="am-input-group am-input-group-sm">
                            <input type="text" class="am-form-field" id="searchKey" placeholder="请输入营销号">
                            <span class="am-input-group-btn">
                            <button class="am-btn am-btn-default" type="button"
                                    onclick="searchPartner();">搜索</button>
                        </span>
                        </div>
                    </div>
                </div>

            </div>

            <div class="am-g">
                <div class="am-u-sm-12">
                    <form class="am-form">
                        <table width="100%"
                                class="am-table am-table-striped am-table-bordered am-table-compact am-text-nowrap"
                                id="list_table">
                            <thead>
                            <tr>
                                <th>ID</th>
                                <th>手机号</th>
                                <th>姓名</th>
                                <th>营销号</th>
                                <th>加入时间</th>
                                <util:logicPermissionTag name="partner:${type}:edit or partner:${type}:delete">
                                    <th>操作</th>
                                </util:logicPermissionTag>
                            </tr>
                            </thead>
                            <tbody>
                            </tbody>
                        </table>
                    </form>
                </div>

            </div>
        </div>
    </div>
    <!-- content end -->
</div>
<!-- main end -->

<!-- footer -->
<%@include file="../common/footer.jsp" %>

<script type="text/javascript">
    var PARTNER_TABLE;
    $(function () {
        //表格初始化
        PARTNER_TABLE = initDataTable({
            ajax: '${webRoot}/partner/${type}/list',
            columns: [
                'id',
                {
                    data: 'administrator',
                    render: function (v) {
                        return v.mobile
                    }
                },
                {
                    data: 'administrator',
                    render: function (v) {
                        return v.name
                    }
                },
                'marketingNumber',
                'createTime'
                <util:logicPermissionTag name="partner:${type}:edit or partner:${type}:delete">
                , {
                    data: 'id',
                    render: function (v, flag, data) {
                        var html = '<div class="am-btn-group am-btn-group-xs">';
                        <%--<util:wholePermission name="partner:${type}:delete">
                        html += '<button type="button" onclick="deletePartner(\'' + data.id + '\');" class="am-btn am-btn-default am-btn-xs">删除</button>';
                        </util:wholePermission>--%>
                        <util:wholePermission name="partner:${type}:edit">
                        html += '<a href="${webRoot}/partner/${type}/edit/' + data.id + '" class="am-btn am-btn-default am-btn-xs am-text-secondary">编辑</a>';
                        </util:wholePermission>
                        html += '</div>';
                        return html;
                    }
                }
                </util:logicPermissionTag>
            ]
        }, function () { //搜索参数JSON数据
            return {
                marketingNumber: $('#searchKey').val()/*,
                 startTime: $('#begin_date').val(),
                 endTime: $('#end_date').val()*/
            };
        });
        /*初始化日期选择插件*/
        /*$('#begin_date, #end_date').datetimepicker({
         locale: 'zh-CN',
         format: 'YYYY-MM-DD HH:mm:ss',
         showTodayButton: true,
         ignoreReadonly:true,
         showClose:true
         });
         $('#begin_date').on('dp.change', function (e) {
         $('#end_date').data('DateTimePicker').minDate(e.date);
         });
         $('#end_date').on('dp.change', function (e) {
         $('#begin_date').data('DateTimePicker').maxDate(e.date);
         });*/

    });

    //搜索
    function searchPartner() {
        PARTNER_TABLE.draw();
    }
    <%--<util:wholePermission name="partner:${type}:delete">
    //删除
    function deletePartner(id) {
        layer.confirm('确定要删除管理员：' + id + '?', {
            title: '删除确认'
        }, function () {
            ajaxRequest({
                url: '${webRoot}/partner/${type}/delete/' + id,
                method: 'DELETE'
            }, function () {
                searchPartner();
            });
        });
    }
    </util:wholePermission>--%>


</script>
</body>
</html>